<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="工单号">
              <a-input placeholder="请输入工单号" v-model="queryParam.orderNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="工作中心">
              <j-tree-select
                v-model="queryParam.workId"
                dict="mdm_work_center,name,id"
                pid-field="pid">
              </j-tree-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目">
              <j-search-select-tag placeholder="请选择项目" v-model="queryParam.projectId"
                                   dict="crm_project,project_name,id"/>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="7" :lg="7" :md="8" :sm="24">
              <a-form-item label="产品描述">
                <a-input placeholder="请输入产品描述" v-model="queryParam.materialDesc"/>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleReport(record)">报工</a>
        </span>

      </a-table>
    </div>

    <pp-work-order-process-report-modal ref="modalForm" @ok="modalFormOk"></pp-work-order-process-report-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import PpWorkOrderProcessReportModal from './modules/PpWorkOrderProcessReportModal'

  export default {
    name: 'PpWorkOrderProcessReportList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      PpWorkOrderProcessReportModal
    },
    data () {
      return {
        description: '生产工单待汇报管理页面',
        // 表头
        columns: [
          {
            title:'工单号',
            align:"center",
            dataIndex: 'orderNo'
          },
          {
            title:'序号',
            align:"center",
            dataIndex: 'seqNo'
          },
          {
            title:'工序名称',
            align:"center",
            dataIndex: 'processName'
          },
          {
            title:'工作中心',
            align:"center",
            dataIndex: 'workId_dictText'
          },
          {
            title:'产品编号',
            align:"center",
            dataIndex: 'materialNo'
          },
          {
            title:'产品描述',
            align:"center",
            dataIndex: 'materialDesc',
            scopedSlots: { customRender: 'materialDesc' },
          },
          {
            title:'单位',
            align:"center",
            dataIndex: 'unit_dictText'
          },
          {
            title:'工单数量',
            align:"center",
            dataIndex: 'orderQty'
          },
          {
            title:'可汇报数量',
            align:"center",
            dataIndex: 'unhandleQty'
          },
          {
            title:'加工数量',
            align:"center",
            dataIndex: 'qty'
          },
          {
            title:'合格数量',
            align:"center",
            dataIndex: 'checkQty'
          },
          {
            title:'报废数量',
            align:"center",
            dataIndex: 'scrapQty'
          },
          {
            title:'返修数量',
            align:"center",
            dataIndex: 'reworkQty'
          },
          {
            title:'项目',
            align:"center",
            dataIndex: 'projectId_dictText',
            scopedSlots: { customRender: 'projectId_dictText' },
          },
          {
            title:'工序编号',
            align:"center",
            dataIndex: 'processNo'
          },
          {
            title:'面积',
            align:"center",
            dataIndex: 'areaNum'
          },
          {
            title:'重量',
            align:"center",
            dataIndex: 'weight'
          },
          {
            title:'计划开工期',
            align:"center",
            dataIndex: 'planStartDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'实际开工期',
            align:"center",
            dataIndex: 'actStartDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'计划完工期',
            align:"center",
            dataIndex: 'planEndDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'实际完工期',
            align:"center",
            dataIndex: 'actEndDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'标准工时',
            align:"center",
            dataIndex: 'standardTime'
          },
          {
            title:'准备工时',
            align:"center",
            dataIndex: 'prepareTime'
          },
          {
            title:'等待工时',
            align:"center",
            dataIndex: 'waitTime'
          },
          {
            title:'工时单位',
            align:"center",
            dataIndex: 'timeUnit_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:100,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/pp/workOrderProcess/reportList",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){

      },
      handleReport: function (record) {
        this.$refs.modalForm.report(record);
        this.$refs.modalForm.disableSubmit = false;
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
